<?php
/**
 * 房间配套管理
 * comfiger
 * 2018-06-13
 **/
namespace Mama\Model;
use Think\Model;

class AccessModel extends Model{
	//定义表名称
	protected $tableName = 'access';

	/**
	 * 获取配套总数
	 **/
	public function getAccessCount($where=array()){
		return $this->where($where)->count();
	}

	/**
	 * 获取列表
	 **/
	public function getAccessList($page, $where=array()){
		return $this->where($where)->order('access_id asc')->page($page, C('PAGE_SIZE'))->select();
	}

	/**
	 * 获取配套总数
	 **/
	public function getAccessMatchingCount($where=array()){
		return M('member_matching')->where($where)->count();
	}

	/**
	 * 获取列表
	 **/
	public function getAccessMatchingList($page, $where=array()){
		return M('member_matching')->where($where)->order('match_id desc')->page($page, C('PAGE_SIZE'))->select();
	}

	public function addAccessMatchingInfo($data){
		return M('member_matching')->addAll($data);
	}

	/**
	 * 添加配套信息
	 **/
	public function addAccessInfo($data){
		return $this->data($data)->add();
	}

	/**
	 * 编辑信息
	 **/
	public function editAccessInfoByAccessId($id, $data){
		return $this->where(array('access_id' => $id))->setField($data);
	}

	/**
	 * 获取详情
	 **/
	public function getAccessInfoById($id){
		return $this->where(array('access_id' => $id))->find();
	}
	
	/**
	 * 获取所有的配套信息
	 **/
	public function getAllAccessList($where=array()){
		return $this->where($where)->order('access_id asc')->select();
	}
}